import { Component } from 'react'
import { Provider } from 'mobx-react'
import {login, setStorage} from '@tarojs/taro'
import {fetchUrlLogin} from '@/api/user'
import store from './store'

import './app.scss'

class App extends Component {
  componentDidMount () {}

  componentDidShow () {}

  componentDidHide () {}

  componentDidCatchError () {}
  
  onLaunch() {
    login().then(res => {
      fetchUrlLogin({code: res.code}).then(res => {
        // console.log(res.token);
        setStorage({
          key: 'token',
          data: res.token 
        })
      })
    })
  }

  // this.props.children 就是要渲染的页面
  render () {
    return (
      <Provider store={store}>
        {this.props.children}
      </Provider>
    )
  }
}

export default App
